<template>
    <div class="header-container">
        <div class="l-content">
            <el-button style="margin-right: 20px" @click="handleMenu" icon="el-icon-menu" size="mini"></el-button>
            <!-- 面包屑 -->
            <el-breadcrumb separator="/">
                <el-breadcrumb-item v-for="item in tags" :key="item.path" :to="{ path: item.path }">{{ item.label }}</el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <div class="r-content">
            <el-dropdown>
                <span class="el-dropdown-link">
                    <img class="user" src="../assets/images/user.png" alt="">
                </span>
                <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item>个人中心</el-dropdown-item>
                    <el-dropdown-item>退出</el-dropdown-item>
                </el-dropdown-menu>
            </el-dropdown>
        </div>
    </div>
</template>

<script>
import { mapState } from 'vuex'
export default{
    data(){
        return{}
    },
    methods:{
        handleMenu(){
            this.$store.commit('collapseMenu')
            // 触发 store 中的 commit 方法。能使用 $store 属性是因为在 main.js 中将 store 挂载到了 vue 实例上
        }
    },
    computed:{
        ...mapState({
            tags: state => state.tab.tabsList
        })
    },
    mounted(){
        console.log(this.tags, 'tags')
    }
}
</script>

<style lang="less" scoped>
.header-container{
    padding: 0 20px;
    background-color: #333;
    height: 60px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    .text{
        color: #fff;
        font-size: 14px;
        margin-left: 10px;
    }
    .r-content{
        .user{
            width: 40px;
            height: 40px;
            border-radius: 50%; // 圆角效果
        }
    }
    .l-content {
        display: flex;
        align-items: center;
        // 因为 el-breadcrumb__item 有身份号，而我们要设置的 span 标签上没有这个内容所以样式会不生效，要用样式穿透
        /deep/.el-breadcrumb__item {
            .el-breadcrumb__inner {
                font-weight: normal;
                &.is-link {
                    color: #666;
                }
            }
            &:last-child {
                .el-breadcrumb__inner {
                    color: #fff;
                }
            }
        }
    }
}
    
</style>